/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "candidate_economic_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CandidateEconomicType.findAll", query = "SELECT c FROM CandidateEconomicType c"),
    @NamedQuery(name = "CandidateEconomicType.findByIdCandidateEconomicType", query = "SELECT c FROM CandidateEconomicType c WHERE c.idCandidateEconomicType = :idCandidateEconomicType"),
    @NamedQuery(name = "CandidateEconomicType.findByDescription", query = "SELECT c FROM CandidateEconomicType c WHERE c.description = :description")})
public class CandidateEconomicType implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "VALUE")
    private int value;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_CANDIDATE_ECONOMIC_TYPE")
    private Integer idCandidateEconomicType;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(mappedBy = "candidateEconomicType", fetch = FetchType.LAZY)
    private List<Candidate> candidateList;

    public CandidateEconomicType() {
    }

    public CandidateEconomicType(Integer idCandidateEconomicType) {
        this.idCandidateEconomicType = idCandidateEconomicType;
    }

    public CandidateEconomicType(Integer idCandidateEconomicType, String description) {
        this.idCandidateEconomicType = idCandidateEconomicType;
        this.description = description;
    }

    public Integer getIdCandidateEconomicType() {
        return idCandidateEconomicType;
    }

    public void setIdCandidateEconomicType(Integer idCandidateEconomicType) {
        this.idCandidateEconomicType = idCandidateEconomicType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<Candidate> getCandidateList() {
        return candidateList;
    }

    public void setCandidateList(List<Candidate> candidateList) {
        this.candidateList = candidateList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCandidateEconomicType != null ? idCandidateEconomicType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CandidateEconomicType)) {
            return false;
        }
        CandidateEconomicType other = (CandidateEconomicType) object;
        if ((this.idCandidateEconomicType == null && other.idCandidateEconomicType != null) || (this.idCandidateEconomicType != null && !this.idCandidateEconomicType.equals(other.idCandidateEconomicType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CandidateEconomicType[ idCandidateEconomicType=" + idCandidateEconomicType + " ]";
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }
    
}
